// 医疗机构查询
<template>
  <div
    class="page-container page-container-havePagination"
    :class="{'page-container-haveFooter':$store.state.settings.showFooter}"
  >
    <!-- 工具栏 -->
    <div class="head-search-container">
      <!-- 搜索 -->
      <el-form
        :inline="true"
        label-position="right"
        label-width="74px"
        size="small"
        :model="searchQuery"
        class="demo-form-inline"
      >
        <el-form-item label="机构名称">
          <el-select
            v-model="searchQuery.organizationId"
            filterable
            placeholder="机构名称"
            class="search-btn"
          >
            <el-option
              v-for="item in orgs"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="机构编号">
          <el-input
            class="search-btn"
            size="small"
            :clearable="true"
            v-model="orgCode"
            placeholder="机构编号"
            @change="search()"
          ></el-input>
        </el-form-item>
        <el-form-item label="APPID">
          <el-input
            class="search-btn"
            size="small"
            :clearable="true"
            v-model="searchQuery.appId"
            placeholder="APPID"
            @change="search()"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="success" class="greenColorBtn" @click="search">查询</el-button>
          <el-button size="small" @click="reloadSearch">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格渲染 -->
    <el-table
      header-row-class-name="table-header-style"
      :row-class-name="tableRowStyle"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      v-loading="loading"
    >
      <el-table-column prop="organizationName" label="机构名称" show-overflow-tooltip></el-table-column>
      <el-table-column prop="organizationId" label="机构编号" show-overflow-tooltip></el-table-column>
      <el-table-column prop="appSecret" label="appSecret" show-overflow-tooltip></el-table-column>
      <el-table-column prop="appId" label="appId" show-overflow-tooltip></el-table-column>
      <el-table-column label="操作" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            round
            type="success"
            class="greenColorBtn"
            @click.stop="look(scope.row)"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页器 -->
    <TablePagination
      :total="total"
      :currentPage="currentPage"
      :pageSize="pageSize"
      @changeSize="changeSize"
      @changePage="changePage"
      :class="['table-pagination',{'table-pagination-haveFooter':$store.state.settings.showFooter}]"
    />
    <!-- 详情弹窗 -->
    <details-popup ref="detailsPopup" />
  </div>
</template>
<script>
import detailsPopup from "./detailsPopup";
import {
  setSearchValue,
  setThisValue,
  deepClone,
  findName,
  splitTime
} from "@/utils/index";
import initData from "@/mixins/req";
import initORG from "@/mixins/org";
import store from "@/store";
export default {
  name: "orgs",
  mixins: [initData, initORG],
  components: { detailsPopup },
  data() {
    return {
      searchQuery: {
        organizationName: "", //机构名称
        organizationId: "", //机构编码
        appId: "" //appid
      },
      orgCode: ""
    };
  },
  created() {
    this.initORG();
    this.init();
  },
  methods: {
    look(row) {
      this.$refs.detailsPopup.show = true;
      this.$refs.detailsPopup.form = row;
    },
    search() {
      this.currentPage=1;
      this.init();
    },
    reloadSearch() {
      setSearchValue(this, this.searchQuery);
      setThisValue(this, ["orgCode"]);
      this.search();
    },
    beforeInit() {
      this.url = store.getters["api/orgs"];
      let searchQuery = deepClone(this.searchQuery);
      if (this.orgCode != "") searchQuery.organizationId = this.orgCode;
      this.searchParams = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        ...searchQuery
      };
      return true;
    }
  },
  filters: {
    rigTime(val) {
      return val ? splitTime(val) : "";
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "~@/assets/styles/page.scss";
@import "~@/assets/styles/table.scss";
</style>
